package com.objectproject.main.model;

import java.sql.Timestamp;
import java.util.ArrayList;

public class MyObject{
	
	private long objectId;
	private MyGroup modificationAuth;
	private MyGroup inheritanceAuth;
	private Timestamp regDate;
	private boolean isInterface;
	private boolean isFinal;
	private boolean isAnonymous;
	private long hits;
	private int depth;
	
	//derived
	private ArrayList<MyObject> ancestorObjects;
	private ArrayList<MyProperty> myProperties;
	
	
	public long getObjectId() {
		return objectId;
	}
	
	public void setObjectId(long objectId) {
		this.objectId = objectId;
	}
	
	
	public MyGroup getModificationAuth() {
		return modificationAuth;
	}

	public void setModificationAuth(MyGroup modificationAuth) {
		this.modificationAuth = modificationAuth;
	}

	public MyGroup getInheritanceAuth() {
		return inheritanceAuth;
	}

	public void setInheritanceAuth(MyGroup inheritanceAuth) {
		this.inheritanceAuth = inheritanceAuth;
	}

	public Timestamp getRegDate() {
		return regDate;
	}

	public void setRegDate(Timestamp regDate) {
		this.regDate = regDate;
	}

	public boolean isInterface() {
		return isInterface;
	}

	public void setInterface(boolean isInterface) {
		this.isInterface = isInterface;
	}

	public boolean isFinal() {
		return isFinal;
	}

	public void setFinal(boolean isFinal) {
		this.isFinal = isFinal;
	}

	public boolean isAnonymous() {
		return isAnonymous;
	}

	public void setAnonymous(boolean isAnonymous) {
		this.isAnonymous = isAnonymous;
	}

	public long getHits() {
		return hits;
	}

	public void setHits(long hits) {
		this.hits = hits;
	}
	
	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}
	
	public ArrayList<MyObject> getAncestorObjects() {
		return ancestorObjects;
	}

	public void setSuperObjects(ArrayList<MyObject> ancestorObjects) {
		this.ancestorObjects = ancestorObjects;
	}

	public ArrayList<MyProperty> getMyProperties() {
		return myProperties;
	}

	public void setMyProperties(ArrayList<MyProperty> myProperties) {
		this.myProperties = myProperties;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof MyObject){
			if(this.objectId == 0 || ((MyObject)obj).objectId == 0){
				return false;
			}else if(this.objectId == ((MyObject)obj).objectId){
				return true;
			}
		}
		return false;
	}

	@Override
	public String toString() {
		
		StringBuilder sb = new StringBuilder();
		sb.append("----------------object---------------\n");
		sb.append("objectId:" + objectId + "\n");
		sb.append("modificationAuth:" + modificationAuth + "\n");
		sb.append("inheritanceAuth:" + inheritanceAuth + "\n");
		sb.append("isAnonymous:" + isAnonymous + "\n");
		sb.append("isFinal:" + isFinal + "\n");
		sb.append("isInterface:" + isInterface + "\n");
		sb.append("hits:" + hits + "\n");
		sb.append("depth:" + depth + "\n");
		
		if(myProperties != null){
			for(MyProperty myProperty:myProperties){
				sb.append(myProperty);
			}
		}
		
		return sb.toString();
		
	}

}
